import logging
import glob
import os

import yagmail
from config.config import smtp_cfg


# 发送邮件
class Email_Utils:
    def __init__(self):
        self.user = smtp_cfg['user']
        self.password = smtp_cfg['password']
        self.host = smtp_cfg['host']

    def send_email(self, log_file_name):
        email = yagmail.SMTP(user=self.user, password=self.password, host=self.host)
        attachments = glob.glob(log_file_name)
        email.send(to=self.user, subject='测试报告', contents='本次生成的测试报告是的使用airtest框架登录自动化测试', attachments=attachments)
        email.close()



